import { getToken,setToken,removeToken } from "@/utils/auth";
import {login} from "@/http/two/api"

const state={
    token:getToken(),
    userInfo:{}  //菜单
}

const mutations={
    // 设置token
    setToken(state,obj){
        state.token = obj;
        setToken(obj)
    },
    // 删除 token
    removeToken(state){
        state.token = null;
        removeToken()
    }
    
}

const actions={
    async login({commit},data) {
        const result=await login(data)
        commit("setToken",result)
    }
}

export default{
  namespaced: true,
     actions,
     mutations,
     state

}